/**
 * 
 */
package com.technodo.gamedata;

import org.json.JSONException;
import org.json.JSONObject;

import com.technodo.enums.ItemStatus;
import com.technodo.utils.GlobalPreferences;
import com.technodo.utils.TechnodoColor;

/**
 * @author Gaurav
 *
 */
public class Tech {

	//////////////////////////////////////////////////////////
	// Elements parsed from the json file

	/**
	 * Unique Name of the Tech
	 */
	private String name;
	/**
	 * Common Name of the tech (for display in UI)
	 */
	private String title;
	/**
	 * Color of the tech
	 */
	private TechnodoColor color;
	/**
	 * Quote related to the tech
	 */
	private String quote;
	/**
	 * Quoter related to the tech
	 * 
	 */
	private String quoter;
	/**
	 * IconPath of this icon
	 */
	private String iconPath;
	/**
	 * Full fledged image of the Tech
	 */
	private String imagePath;

	//////////////////////////////////////////////////////////////////
	// Elements which are dynamic
	/**
	 * Current Status of the item
	 */
	private ItemStatus status;
	/**
	 * Owner of the Item
	 */
	private PlayerBoard playerBoard;


	/**
	 * Parses json and creates a new tech object
	 * 
	 * @param jsonTech
	 */
	public Tech(JSONObject jsonTech) throws IllegalArgumentException, JSONException {

		// Parse the Json tech and convert to Java data structure
		name    = jsonTech.optString("name");
		title   = jsonTech.optString("title");
		color   = new TechnodoColor(jsonTech.optString("color"));
		quote	= jsonTech.optString("quote", "Magenta and Purple are the same, atleast in RGB sense");
		quoter  = jsonTech.optString("quoter", "Gaurav Roy");
		iconPath= jsonTech.optString("icon", GlobalPreferences.defaultTechIcon);
		imagePath= jsonTech.optString("image", GlobalPreferences.defaultTechIcon);

		// Initialise non Json variables
		setPlayerBoard(null);
		setStatus(ItemStatus.AVAILABLE);
	}


	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}
	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}
	/**
	 * @return the color
	 */
	public TechnodoColor getColor() {
		return color;
	}
	/**
	 * @param color the color to set
	 */
	public void setColor(TechnodoColor color) {
		this.color = color;
	}
	/**
	 * @return the quote
	 */
	public String getQuote() {
		return quote;
	}
	/**
	 * @param quote the quote to set
	 */
	public void setQuote(String quote) {
		this.quote = quote;
	}
	/**
	 * @return the quoter
	 */
	public String getQuoter() {
		return quoter;
	}
	/**
	 * @param quoter the quoter to set
	 */
	public void setQuoter(String quoter) {
		this.quoter = quoter;
	}
	/**
	 * @return the iconPath
	 */
	public String getIconPath() {
		return iconPath;
	}
	/**
	 * @param iconPath the iconPath to set
	 */
	public void setIconPath(String iconPath) {
		this.iconPath = iconPath;
	}
	/**
	 * @return the imagePath
	 */
	public String getImagePath() {
		return imagePath;
	}
	/**
	 * @param imagePath the imagePath to set
	 */
	public void setImagePath(String imagePath) {
		this.imagePath = imagePath;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Tech [name=" + name + ", title=" + title + ", color=" + color.toString()
				+ ", quote=" + quote + ", quoter=" + quoter + ", iconPath="
				+ iconPath + ", imagePath=" + imagePath + ", status=" + status
				+ "]";
	}


	public PlayerBoard getPlayerBoard() {
		return playerBoard;
	}


	public void setPlayerBoard(PlayerBoard playerBoard) {
		this.playerBoard = playerBoard;
	}


	public ItemStatus getStatus() {
		return status;
	}


	public void setStatus(ItemStatus status) {
		this.status = status;
	}





}
